<!DOCTYPE HTML>
<script type="module">
import {CHALLENGE, PUBLIC_KEY_PARAMETERS, PUBLIC_KEY_USER} from './test-inputs.js';
import {TestAuthenticatorManager} from './virtual-navigator-credentials.js';

let queryParams = new URLSearchParams(window.location.search);
var relyingPartyId = queryParams.has('rpId') ? queryParams.get('rpId') : document.domain;
var customPublicKey = {
    challenge: CHALLENGE,
    rp: { id: relyingPartyId, name: "Acme" },
    user: PUBLIC_KEY_USER,
    pubKeyCredParams: PUBLIC_KEY_PARAMETERS,
};
let responder =  window.opener || window.parent;

const manager = new TestAuthenticatorManager;
manager.createAuthenticator().then(() => {
  return navigator.credentials.create({publicKey : customPublicKey});
}).then(r => responder.postMessage("SUCCESS", "*"))
  .catch(t => responder.postMessage(t.name, "*"));;
</script>
